#include "accel.h"
#include "camera.h"
#include "scene.h"
#include "material.h"

namespace csupbr {

    Scene::Scene(std::shared_ptr<Accel> accel,
                 std::shared_ptr<Camera> camera)
        : accel(accel), camera(camera) {}

    bool Scene::intersect(const Ray &ray, Intersection &isct) const {
        return accel->intersect(ray, isct);
    }
    bool Scene::intersectP(const Ray &ray, bool blend_test) const {
        return accel->intersectP(ray, blend_test);
    }

    Spectrum Scene::sample_li(LightRecord &lRec, const Intersection &spit,
                                                     const Point2f &sample, Float &pdf) const {
        auto light = lights[sample.x * (lights.size() - 1)];
        return light->sample_li(lRec, spit, sample, pdf);
    }
}